<template>
  <!-- 复位 -->
  <div></div>
</template>

<script lang="ts">
import { Vue, Component, Watch } from "vue-property-decorator";
import Template from "./CTemplate.vue";
@Component({ name: "Restoration" })
export default class extends Template {
  get initialExtent2d() {
    return this.$store.getters["view/initialExtent2d"];
  }

  // 外部控制复位
  get status() {
    return this.$store.getters["view/restoration"];
  }

  @Watch("status")
  handleStatusChange() {
    if (this.status) {
      this.restoration();
      this.$store.commit("view/setRestoration", false);
    }
  }

  // 复位
  private restoration() {
    const view = this.view;
    if (view) {
      view.extent = {
        xmin: this.initialExtent2d.xMin,
        xmax: this.initialExtent2d.xMax,
        ymin: this.initialExtent2d.yMin,
        ymax: this.initialExtent2d.yMax,
        spatialReference: this.view.spatialReference
      };
    }
  }
}
</script>

<style lang="scss" scoped></style>
